package com.guofen.controller.sjq;

import com.guofen.pojo.SjqDeodorizationRunningThree;
import com.guofen.service.sjq.SjqDeodorizationRunningThreeService;
import com.guofen.util.result.Result;
import com.guofen.util.result.ResultGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/sjq/SjqDeodorizationRunningThree")
@Controller
@Api(tags = "SjqDeodorizationRunningThreeController", description = "除臭生产现场记录表(除臭3)")
public class SjqDeodorizationRunningThreeController {
    @Autowired
    private SjqDeodorizationRunningThreeService sjqDeodorizationRunningThreeService;

    @ApiOperation("添加记录")
    @RequestMapping(value = "/addForm", method = RequestMethod.POST)
    @ResponseBody
    public Result addForm(@ApiParam(name = "solid_liquid_atomizing_system", value = "固液分离车间除臭系统-雾化系统", required = true) @RequestParam(required = true) String solid_liquid_atomizing_system,
                          @ApiParam(name = "solid_liquid_filter_1", value = "固液分离车间除臭系统-1#过滤器", required = true) @RequestParam(required = true) String solid_liquid_filter_1,
                          @ApiParam(name = "solid_liquid_filter_2", value = "固液分离车间除臭系统-2#过滤器", required = true) @RequestParam(required = true) String solid_liquid_filter_2,
                          @ApiParam(name = "solid_liquid_spray_nozzle_1", value = "固液分离车间除臭系统-1#水洗喷嘴", required = true) @RequestParam(required = true) String solid_liquid_spray_nozzle_1,
                          @ApiParam(name = "solid_liquid_spray_nozzle_2", value = "固液分离车间除臭系统-2#水洗喷嘴", required = true) @RequestParam(required = true) String solid_liquid_spray_nozzle_2,
                          @ApiParam(name = "solid_liquid_spray_filter_1", value = "固液分离车间除臭系统-1#喷淋滤嘴", required = true) @RequestParam(required = true) String solid_liquid_spray_filter_1,
                          @ApiParam(name = "solid_liquid_spray_filter_2", value = "固液分离车间除臭系统-2#喷淋滤嘴", required = true) @RequestParam(required = true) String solid_liquid_spray_filter_2,
                          @ApiParam(name = "solid_liquid_fan_operation_1", value = "固液分离车间除臭系统-1#风机运行情况", required = true) @RequestParam(required = true) String solid_liquid_fan_operation_1,
                          @ApiParam(name = "solid_liquid_fan_operation_2", value = "固液分离车间除臭系统-2#风机运行情况", required = true) @RequestParam(required = true) String solid_liquid_fan_operation_2,
                          @ApiParam(name = "compost_atomizing_system", value = "堆肥车间除臭系统-雾化系统", required = true) @RequestParam(required = true) String compost_atomizing_system,
                          @ApiParam(name = "compost_filter_1", value = "堆肥车间除臭系统-1#过滤器", required = true) @RequestParam(required = true) String compost_filter_1,
                          @ApiParam(name = "compost_filter_2", value = "堆肥车间除臭系统-2#过滤器", required = true) @RequestParam(required = true) String compost_filter_2,
                          @ApiParam(name = "compost_spray_nozzle_1", value = "堆肥车间除臭系统-1#水洗喷嘴", required = true) @RequestParam(required = true) String compost_spray_nozzle_1,
                          @ApiParam(name = "compost_spray_nozzle_2", value = "堆肥车间除臭系统-2#水洗喷嘴", required = true) @RequestParam(required = true) String compost_spray_nozzle_2,
                          @ApiParam(name = "compost_spray_filter_1", value = "堆肥车间除臭系统-1#喷淋滤嘴", required = true) @RequestParam(required = true) String compost_spray_filter_1,
                          @ApiParam(name = "compost_spray_filter_2", value = "堆肥车间除臭系统-2#喷淋滤嘴", required = true) @RequestParam(required = true) String compost_spray_filter_2,
                          @ApiParam(name = "compost_fan_operation_1", value = "堆肥车间除臭系统-1#风机运行情况", required = true) @RequestParam(required = true) String compost_fan_operation_1,
                          @ApiParam(name = "compost_fan_operation_2", value = "堆肥车间除臭系统-2#风机运行情况", required = true) @RequestParam(required = true) String compost_fan_operation_2,
                          @ApiParam(name = "flocculation_atomizing_system", value = "絮凝车间除臭系统-雾化系统", required = true) @RequestParam(required = true) String flocculation_atomizing_system,
                          @ApiParam(name = "flocculation_plasma_system", value = "絮凝车间除臭系统-等离子系统", required = true) @RequestParam(required = true) String flocculation_plasma_system,
                          @ApiParam(name = "flocculation_fan_operation", value = "絮凝车间除臭系统-风机运行情况", required = true) @RequestParam(required = true) String flocculation_fan_operation,
                          @ApiParam(name = "operator", value = "操作人", required = true) @RequestParam(required = true) String operator,
                          @ApiParam(name = "examiner", value = "检查人", required = true) @RequestParam(required = true) String examiner,
                          @ApiParam(name = "remarks", value = "备注", required = true) @RequestParam(required = true) String remarks
                          ){

        if (sjqDeodorizationRunningThreeService.addForm(solid_liquid_atomizing_system, solid_liquid_filter_1, solid_liquid_filter_2,
                solid_liquid_spray_nozzle_1, solid_liquid_spray_nozzle_2, solid_liquid_spray_filter_1,
                solid_liquid_spray_filter_2, solid_liquid_fan_operation_1, solid_liquid_fan_operation_2,
                compost_atomizing_system, compost_filter_1, compost_filter_2,
                compost_spray_nozzle_1, compost_spray_nozzle_2, compost_spray_filter_1,
                compost_spray_filter_2, compost_fan_operation_1, compost_fan_operation_2,
                flocculation_atomizing_system, flocculation_plasma_system, flocculation_fan_operation,
                operator, examiner, remarks))
            return ResultGenerator.genSuccessResult();
        else
            return ResultGenerator.genFailResult("保存失败");
    }

    @ApiOperation("查询最新记录")
    @RequestMapping(value = "/getLast", method = RequestMethod.GET)
    @ResponseBody
    public Result getLast(){
        if (sjqDeodorizationRunningThreeService.findForm() != null)
            return ResultGenerator.genSuccessResult(sjqDeodorizationRunningThreeService.findForm());
        else
            return ResultGenerator.genFailResult("暂无记录");
    }


    @ApiOperation("删除记录")
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    @ResponseBody
    public Result delete(@ApiParam(name="id",value="ID",required=true) @RequestParam Integer id) {
        return ResultGenerator.genSuccessResult(sjqDeodorizationRunningThreeService.delete(id));
    }

    @ApiOperation("修改记录")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ResponseBody
    public Result update(@ApiParam(name="id",value="ID",required=true) @RequestParam(required = true) Integer id,
                         @ApiParam(name = "date", value = "日期", required = false) @RequestParam(required = false) String date,
                         @ApiParam(name = "solid_liquid_atomizing_system", value = "固液分离车间除臭系统-雾化系统", required = false) @RequestParam(required = false) String solid_liquid_atomizing_system,
                         @ApiParam(name = "solid_liquid_filter_1", value = "固液分离车间除臭系统-1#过滤器", required = false) @RequestParam(required = false) String solid_liquid_filter_1,
                         @ApiParam(name = "solid_liquid_filter_2", value = "固液分离车间除臭系统-2#过滤器", required = false) @RequestParam(required = false) String solid_liquid_filter_2,
                         @ApiParam(name = "solid_liquid_spray_nozzle_1", value = "固液分离车间除臭系统-1#水洗喷嘴", required = false) @RequestParam(required = false) String solid_liquid_spray_nozzle_1,
                         @ApiParam(name = "solid_liquid_spray_nozzle_2", value = "固液分离车间除臭系统-2#水洗喷嘴", required = false) @RequestParam(required = false) String solid_liquid_spray_nozzle_2,
                         @ApiParam(name = "solid_liquid_spray_filter_1", value = "固液分离车间除臭系统-1#喷淋滤嘴", required = false) @RequestParam(required = false) String solid_liquid_spray_filter_1,
                         @ApiParam(name = "solid_liquid_spray_filter_2", value = "固液分离车间除臭系统-2#喷淋滤嘴", required = false) @RequestParam(required = false) String solid_liquid_spray_filter_2,
                         @ApiParam(name = "solid_liquid_fan_operation_1", value = "固液分离车间除臭系统-1#风机运行情况", required = false) @RequestParam(required = false) String solid_liquid_fan_operation_1,
                         @ApiParam(name = "solid_liquid_fan_operation_2", value = "固液分离车间除臭系统-2#风机运行情况", required = false) @RequestParam(required = false) String solid_liquid_fan_operation_2,
                         @ApiParam(name = "compost_atomizing_system", value = "堆肥车间除臭系统-雾化系统", required = false) @RequestParam(required = false) String compost_atomizing_system,
                         @ApiParam(name = "compost_filter_1", value = "堆肥车间除臭系统-1#过滤器", required = false) @RequestParam(required = false) String compost_filter_1,
                         @ApiParam(name = "compost_filter_2", value = "堆肥车间除臭系统-2#过滤器", required = false) @RequestParam(required = false) String compost_filter_2,
                         @ApiParam(name = "compost_spray_nozzle_1", value = "堆肥车间除臭系统-1#水洗喷嘴", required = false) @RequestParam(required = false) String compost_spray_nozzle_1,
                         @ApiParam(name = "compost_spray_nozzle_2", value = "堆肥车间除臭系统-2#水洗喷嘴", required = false) @RequestParam(required = false) String compost_spray_nozzle_2,
                         @ApiParam(name = "compost_spray_filter_1", value = "堆肥车间除臭系统-1#喷淋滤嘴", required = false) @RequestParam(required = false) String compost_spray_filter_1,
                         @ApiParam(name = "compost_spray_filter_2", value = "堆肥车间除臭系统-2#喷淋滤嘴", required = false) @RequestParam(required = false) String compost_spray_filter_2,
                         @ApiParam(name = "compost_fan_operation_1", value = "堆肥车间除臭系统-1#风机运行情况", required = false) @RequestParam(required = false) String compost_fan_operation_1,
                         @ApiParam(name = "compost_fan_operation_2", value = "堆肥车间除臭系统-2#风机运行情况", required = false) @RequestParam(required = false) String compost_fan_operation_2,
                         @ApiParam(name = "flocculation_atomizing_system", value = "絮凝车间除臭系统-雾化系统", required = false) @RequestParam(required = false) String flocculation_atomizing_system,
                         @ApiParam(name = "flocculation_plasma_system", value = "絮凝车间除臭系统-等离子系统", required = false) @RequestParam(required = false) String flocculation_plasma_system,
                         @ApiParam(name = "flocculation_fan_operation", value = "絮凝车间除臭系统-风机运行情况", required = false) @RequestParam(required = false) String flocculation_fan_operation,
                         @ApiParam(name = "operator", value = "操作人", required = false) @RequestParam(required = false) String operator,
                         @ApiParam(name = "examiner", value = "检查人", required = false) @RequestParam(required = false) String examiner,
                         @ApiParam(name = "remarks", value = "备注", required = false) @RequestParam(required = false) String remarks
                         ) {

        SjqDeodorizationRunningThree sjqDeodorizationRunningThree = new SjqDeodorizationRunningThree();

        sjqDeodorizationRunningThree.setId(id);
        sjqDeodorizationRunningThree.setDate(date);

        sjqDeodorizationRunningThree.setSolidLiquidAtomizingSystem(solid_liquid_atomizing_system);
        sjqDeodorizationRunningThree.setSolidLiquidFilter1(solid_liquid_filter_1);
        sjqDeodorizationRunningThree.setSolidLiquidFilter2(solid_liquid_filter_2);
        sjqDeodorizationRunningThree.setSolidLiquidSprayNozzle1(solid_liquid_spray_nozzle_1);
        sjqDeodorizationRunningThree.setSolidLiquidSprayNozzle2(solid_liquid_spray_nozzle_2);
        sjqDeodorizationRunningThree.setSolidLiquidSprayFilter1(solid_liquid_spray_filter_1);
        sjqDeodorizationRunningThree.setSolidLiquidSprayFilter2(solid_liquid_spray_filter_2);
        sjqDeodorizationRunningThree.setSolidLiquidFanOperation1(solid_liquid_fan_operation_1);
        sjqDeodorizationRunningThree.setSolidLiquidFanOperation2(solid_liquid_fan_operation_2);

        sjqDeodorizationRunningThree.setCompostAtomizingSystem(compost_atomizing_system);
        sjqDeodorizationRunningThree.setCompostFilter1(compost_filter_1);
        sjqDeodorizationRunningThree.setCompostFilter2(compost_filter_2);
        sjqDeodorizationRunningThree.setCompostSprayNozzle1(compost_spray_nozzle_1);
        sjqDeodorizationRunningThree.setCompostSprayNozzle2(compost_spray_nozzle_2);
        sjqDeodorizationRunningThree.setCompostSprayFilter1(compost_spray_filter_1);
        sjqDeodorizationRunningThree.setCompostSprayFilter2(compost_spray_filter_2);
        sjqDeodorizationRunningThree.setCompostFanOperation1(compost_fan_operation_1);
        sjqDeodorizationRunningThree.setCompostFanOperation2(compost_fan_operation_2);

        sjqDeodorizationRunningThree.setFlocculationAtomizingSystem(flocculation_atomizing_system);
        sjqDeodorizationRunningThree.setFlocculationPlasmaSystem(flocculation_plasma_system);
        sjqDeodorizationRunningThree.setFlocculationFanOperation(flocculation_fan_operation);

        sjqDeodorizationRunningThree.setOperator(operator);
        sjqDeodorizationRunningThree.setExaminer(examiner);
        sjqDeodorizationRunningThree.setRemarks(remarks);

        return ResultGenerator.genSuccessResult(sjqDeodorizationRunningThreeService.update(sjqDeodorizationRunningThree));
    }

    @ApiOperation("查找记录")
    @RequestMapping(value = "/select",method = RequestMethod.POST)
    @ResponseBody
    public Result select(@ApiParam(name="pageSize",value="页容量",required=true) @RequestParam(required = true) Integer pageSize,
                         @ApiParam(name="currentPage",value="当前页",required=true) @RequestParam(required = true) Integer currentPage,
                         @ApiParam(name="startTime",value="开始时间", required = false) @RequestParam(required = false)Long startTime,
                         @ApiParam(name="endTime",value="截止时间", required = false) @RequestParam(required = false)Long endTime) {
        if (startTime == null || endTime == null)
            return ResultGenerator.genSuccessResult(sjqDeodorizationRunningThreeService.get(pageSize, currentPage));
        else
            return ResultGenerator.genSuccessResult(sjqDeodorizationRunningThreeService.getByTime(pageSize, currentPage, startTime, endTime));
    }
}
